/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package actions;

import beans.DeportistaTupla;
import herramientas.EnviadorMail;
import herramientas.baseDatos;
import herramientas.notificar;
import java.util.ArrayList;
import java.util.Iterator;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

/**
 *
 * @author scb
 */
public class AprobarSuspensionAction extends org.apache.struts.action.Action {

    /*
     * forward name="success" path=""
     */
    private static final String SUCCESS = "success";

    /**
     * This is the action called from the Struts framework.
     *
     * @param mapping The ActionMapping used to select this instance.
     * @param form The optional ActionForm bean for this request.
     * @param request The HTTP Request we are processing.
     * @param response The HTTP Response we are processing.
     * @throws java.lang.Exception
     * @return
     */
    @Override
    public ActionForward execute(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {
        String idsusp = request.getParameter("id");
	String nombre = request.getParameter("nombre");
        if (idsusp != null) {
            baseDatos.getInstance().aprobarSuspension(Integer.parseInt(idsusp));
//            ArrayList<String> lista = baseDatos.getInstance().deportistaSuspendido(idsusp);
//            String usbid;
//            String cuerpo = "Usted ha sido suspendido de los beneficios nutricionales "
//                    + "otorgados a los deportistas.";
//            for (Iterator<String> it = lista.iterator(); it.hasNext(); ) {
//                usbid = it.next();
//                if (!usbid.equals(null)){
//                    EnviadorMail mail = new EnviadorMail(usbid+"@usb.ve", "Suspension", cuerpo);
//                    cuerpo = "El usuario dueño del carnet: " +usbid+" ha sido suspendido"
//                            + " de los beneficios nutricionales otorgados a los deportistas.";
//                    mail = new EnviadorMail("nutricion@usb.ve", "Suspension", cuerpo);
//                    mail = new EnviadorMail("deportes@usb.ve", "Suspension", cuerpo);
//                } 
//            }
//                
        }
        return mapping.findForward(SUCCESS);
    }
}
